package com.xidian.zhiancloud.service.ypp.processmanage;


import com.xidian.zhiancloud.dao.SysProcessManagementMapper;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.exception.CustomizeException;
import com.xidian.zhiancloud.model.SysProcessManagement;
import com.xidian.zhiancloud.model.SysProcessManagementExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DangerousGoodsCollectApplyService {

    @Autowired
    private SysProcessManagementMapper sysProcessManagementMapper;

    public List<SysProcessManagement> getById(String classify) {
        SysProcessManagementExample sysProcessManagementExample = new SysProcessManagementExample();
        SysProcessManagementExample.Criteria criteria = sysProcessManagementExample.createCriteria();
        criteria.andClassifyEqualTo(classify);
        List<SysProcessManagement> sysProcessManagementList = sysProcessManagementMapper.selectByExample(sysProcessManagementExample);
        if (sysProcessManagementList == null){
            throw new CustomizeException(GeneralResponseEnums.SYSTEM_ERROR);
        }
        return sysProcessManagementList;
    }

    public void deleteById(Long id) {
        int result = sysProcessManagementMapper.deleteByPrimaryKey(id);
        if (result == 0) {
            throw new CustomizeException(GeneralResponseEnums.SYSTEM_ERROR);
        }
    }
}
